import Base from 'models/base';

import SystemUtil from 'utils/systemUtil';

export default class GoodsDetail extends Base {
  constructor(goods) {
    super();

    this.id = goods.goodsDefId;
    this.defId = goods.goodsDefId;
    this.name = goods.goodsName;
    this.monthCount = goods.monthTradeCount||0;
    this.price = goods.goodsModelSalePrice;
    this.description = goods.goodsDescription;
    this.tip = goods.goodsTips;
    this.branchId = goods.branchId;

    let partnerId = goods.partnerId;
    if (SystemUtil.isEmpty(partnerId)) {
      this.partnerId = null;
    } else {
      this.partnerId = partnerId;
    }

    let pic = goods.goodsPic;
    this.pics = pic.split(',');
  }

  getShopData() {
    let partnerId = this.partnerId;
    if (partnerId !== null) {
      return {
        partnerId
      };
    }

    return {
      branchId: this.branchId
    };
  }
}
